package com.flycms.module.agent;

import org.springframework.jdbc.core.RowMapper;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.concurrent.ConcurrentHashMap;

/**
 * @author huangzt
 * @version 1.0
 * @date 2020/3/1 19:10
 */
public class VisitRowMapper implements RowMapper<ConcurrentHashMap<String, Long>> {
    @Override
    public ConcurrentHashMap<String, Long> mapRow(ResultSet resultSet, int i) throws SQLException {
        ConcurrentHashMap<String, Long> map = new ConcurrentHashMap<>(16);
        //获取结果集中的数据
        Long uniqueVisitor = resultSet.getLong("unique_visitor");
        Long pageView = resultSet.getLong("page_view");
        Long ipCount = resultSet.getLong("ip_count");
        Long newUniqueVisitor = resultSet.getLong("new_unique_visitor");
        Long solutionVisitor = resultSet.getLong("solution_visitor");
        //把数据封装成VisitPersonVo对象
        map.put("unique_visitor", uniqueVisitor);
        map.put("page_view", pageView);
        map.put("ip_count", ipCount);
        map.put("new_unique_visitor", newUniqueVisitor);
        map.put("solution_visitor",solutionVisitor);
        return map;
    }
}
